package it.struts.helloworld.services;


import it.struts.helloworld.utils.HibernateUtils;

import org.hibernate.Query;
import org.hibernate.Session;

public class CarrelloService {
	
	
	
	
	
	public static double getPrezzoPerProdotto(Integer productid) throws
	java.sql.SQLException {
		
		try{
		
			Session sess;
		sess= HibernateUtils.getSessionFactory();
		Query query = sess.createQuery("select prezzo from prodotti where prodotti_id = :prodotti_id");
		query.setParameter("prodotti_id",productid);
		return (double) query.uniqueResult();
		
	}
	catch(Exception exep){
	exep.printStackTrace();
}
		return (Double) null;

	}

}
